var show_selected_stock_name = '';//全局变量，被搜索的股票名称
var show_selected_ts_code = '';//全局变量，被搜索的股票ts代码
var show_selected_stock_name_list = '';//全局变量，被搜索的股票名称
var show_selected_ts_code_list = '';//全局变量，被搜索的股票ts代码
/******
 * 加载页面函数，分别判断是否从相关页面跳转而来，并作相关处理（20200209）
 * *****/
window.onload = window_onload();//窗体加载后执行

function window_onload() {
    show_selected_stock_name = $("#p_stock_name").text();
    show_selected_ts_code = $("#p_ts_code").text();
    query_stockinfo(show_selected_stock_name, show_selected_ts_code);
}


/*******
 * 判断是否从分析页面跳转而来
 */
// function fromAnalysis() {
//     /*
//      *判断是否从其他页面跳转而来，如果是则获取url中的信息
//      */
//     var url = decodeURI(window.location.href);//获取当前浏览器的url,decodeURI函数防止中文乱码
//     isanalysis = url.indexOf("analysis");//analysis，如果有，说明是从analysis页面跳转而来的，就执行下面的程序
//     if (isanalysis != -1) {//由analysis页面跳转而来
//
//         var a = url.indexOf("ts_code");
//         index_ts_code = url.substring(a + "ts_code".length + 1, a + "ts_code".length + 10);//获取股票代码
//         var a = url.indexOf("name");
//         index_stock_name = url.substring(a + "name".length + 1);//获取股票名称
//         $("header").hide();
//         $("nav").hide();
//         query_stockinfo(index_stock_name, index_ts_code);
//         //query_stock_K_line();
//
//
//     }
// }


/***********************
 查询股票信息并显示在广告栏中
 **********************/
function query_stockinfo(searchtxt = show_selected_stock_name, tscode = show_selected_ts_code) {

    if (show_selected_stock_name_list.length > 0) {
        indexof = show_selected_stock_name_list.indexOf(searchtxt);
        show_selected_stock_name = searchtxt;
    }

    if (show_selected_ts_code_list.length > 0) {
        show_selected_ts_code = show_selected_ts_code_list[indexof];
    } else {
        show_selected_ts_code = tscode
    }

    if (tscode.length > 0 && tscode != -1) {
        query_daily(tscode);
        query_daily_basic(tscode);
        query_block_trade(tscode);
        query_moneyflow(tscode);
        query_stock_K_line();
    } else {
        query_daily(searchtxt);
        query_daily_basic(searchtxt);
        query_block_trade(searchtxt);
        query_moneyflow(searchtxt);
        query_stock_K_line();
    }

    $("#btn_add_attention").removeAttr('disabled');
    window.setInterval(query_stock_K_line, 600000);

}

function query_daily(searchtxt) {
    $.ajax({
        url: "/stock/get_selected_stock/",
        type: "GET",
        data: {cmd_class: "query", command: "daily", stockname: searchtxt},
        success: function (callback) {
            var data = eval(callback);//解析json数据，json需要用eval函数解析后才方便使用
            var daily_column = eval(data['columns']);
            var daily_data = eval(data['data']);
            // $("#panel_daily").empty();
            $("#div_daily").empty();
            $("#div_daily").append("<div style='color: #ffffff' align='center'>" + searchtxt + ":每日交易信息</div>");

            // $("#panel_daily").append("<table id='table_daily'></table> ");
            $("#div_daily").append("<table id='table_daily' class='selected_stock'></table> ");
            $("#table_daily").append("<tbody id='tbody_daily'></tbody> ");
            $("#tbody_daily").append("<tr id='tr_daily_title' class='selected_stock'></tr> ");


            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['trade_date'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['open'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['high'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['low'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['close'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['pre_close'] + "</th> ");

            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['change'] + "</th> ");

            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['pct_chg'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['vol'] + "</th> ");
            $("#tr_daily_title").append("<th scope='col' class='selected_stock'>" + daily_column['amount'] + "</th> ");


            for (i = 0; i < daily_data.length; ++i) {
                $("#tbody_daily").append("<tr></tr> ");
                // $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ts_code'] + "</td> ");
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['trade_date'] + "</td> ");
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['open'] + "</td> ");
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['high'] + "</td> ");
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['low'] + "</td> ");
                // $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['close'] + "</td> ");
                if (daily_data[i].fields['open'] > daily_data[i].fields['close'] ){
                    $("#tbody_daily:last-child").append("<td style='color:greenyellow;' class='selected_stock'>" + daily_data[i].fields['close'] + "</td> ");
                }
                else{
                    $("#tbody_daily:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['close'] + "</td> ");
                }

                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['pre_close'] + "</td> ");
                // $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['change'] + "</td> ");
                if (daily_data[i].fields['change'] >= 0) {
                    $("#tbody_daily:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['change'] + "</td> ");
                } else {
                    $("#tbody_daily:last-child").append("<td style='color:greenyellow;' class='selected_stock'>" + daily_data[i].fields['change'] + "</td> ");
                }
                // $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['pct_chg'].toFixed(2) + "</td> ");
                if (daily_data[i].fields['pct_chg'].toFixed(2) >= 0) {
                    $("#tbody_daily:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['pct_chg'].toFixed(2) + "</td> ");
                } else {
                    $("#tbody_daily:last-child").append("<td style='color:greenyellow;' class='selected_stock'>" + daily_data[i].fields['pct_chg'].toFixed(2) + "</td> ");
                }
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['vol'] + "</td> ");
                $("#tbody_daily:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['amount'] + "</td> ");
            }
            //设置全局变量名,是否存在，可以后面判断，如果是从分析链接过来的，则直接在分析列表中设置
            show_selected_stock_name = searchtxt;
            show_selected_ts_code = daily_data[0].fields['ts_code'];
        },
        error: function () {
            alert('每日交易查询失败');
        }
    })
}

function query_daily_basic(searchtxt) {

    $.ajax({
        url: "/stock/get_selected_stock/",
        type: "GET",
        data: {cmd_class: "query", command: "daily_basic", stockname: searchtxt},
        success: function (callback) {
            var data = eval(callback);
            var daily_column = eval(data['columns']);
            var daily_data = eval(data['data']);
            // alert(daily_column);
            // alert(daily_data);

            // $("#panel_daily_basic").empty();
            // $("#panel_daily_basic").append("<table id='table_daily_baisc'></table> ");
            $("#div_daily_basic").empty();
            $("#div_daily_basic").append("<div style='color: #ffffff' align='center'>" + searchtxt + ":每日交易指标</div>");
            $("#div_daily_basic").append("<table id='table_daily_baisc' class='selected_stock'></table> ");
            $("#table_daily_baisc").append("<tbody id='tbody_daily_baisc' ></tbody> ");
            $("#tbody_daily_baisc").append("<tr id='tr_daily_baisc_title' class='selected_stock'></tr> ");


            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['trade_date'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['close'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['turnover_rate'] + "</th> ");

            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['turnover_rate_f'] + "</th> ");

            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['volume_ratio'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['pe'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['pe_ttm'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['pb'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['ps'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['ps_ttm'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['total_share'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['float_share'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['free_share'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['total_mv'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['circ_mv'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['dv_ratio'] + "</th> ");
            $("#tr_daily_baisc_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['dv_ttm'] + "</th> ");

            for (i = 0; i < daily_data.length; ++i) {
                $("#tbody_daily_baisc").append("<tr></tr> ");
                // $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ts_code'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['trade_date'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['close'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['turnover_rate'] + "</td> ");
                if (daily_data[i].fields['turnover_rate_f'] > 2) {
                    $("#tbody_daily_baisc:last-child").append("<td style='color: #dc3545;' class='selected_stock'>" + daily_data[i].fields['turnover_rate_f'] + "</td> ");
                } else {
                    $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['turnover_rate_f'] + "</td> ");

                }
                // $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['turnover_rate_f'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['volume_ratio'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['pe'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['pe_ttm'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['pb'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ps'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ps_ttm'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['total_share'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['float_share'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['free_share'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['total_mv'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['circ_mv'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['dv_ratio'] + "</td> ");
                $("#tbody_daily_baisc:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['dv_ttm'] + "</td> ");
            }
        },
        error: function () {
            alert('获取交易指标失败');
        }
    })
}

function query_block_trade(searchtxt) {

    $.ajax({
        url: "/stock/get_selected_stock/",
        type: "GET",
        data: {cmd_class: "query", command: "block_trade", stockname: searchtxt},
        success: function (callback) {
            var data = eval(callback);
            var daily_column = eval(data['columns']);
            var daily_data = eval(data['data']);
            // alert(daily_column);
            // alert(daily_data);

            // $("#panel_block_trade").empty();
            // $("#panel_block_trade").append("<table id='table_block_trade'></table> ");

            $("#div_block_trade").empty();
            $("#div_block_trade").append("<div style='color: #ffffff' align='center'>" + searchtxt + ":大宗交易</div>");
            $("#div_block_trade").append("<table id='table_block_trade'  class='selected_stock'></table> ");
            $("#table_block_trade").append("<tbody id='tbody_block_trade'></tbody> ");
            $("#tbody_block_trade").append("<tr id='tr_block_trade_title'  class='selected_stock'></tr> ");

            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['trade_date'] + "</td> ");
            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['price'] + "</td> ");
            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['vol'] + "</td> ");
            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['amount'] + "</td> ");
            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['buyer'] + "</td> ");
            $("#tr_block_trade_title").append("<th scope='col' class='selected_stock' class='selected_stock'>" + daily_column['seller'] + "</td> ");


            for (i = 0; i < daily_data.length; ++i) {
                $("#tbody_block_trade").append("<tr></tr> ");
                // $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ts_code'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['trade_date'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['price'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['vol'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['amount'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['buyer'] + "</td> ");
                $("#tbody_block_trade:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['seller'] + "</td> ");

            }
        },

        error: function () {
            alert('大宗交易查询失败');
        }
    })
}

function query_moneyflow(searchtxt) {

    $.ajax({
        url: "/stock/get_selected_stock/",
        type: "GET",
        data: {cmd_class: "query", command: "moneyflow", stockname: searchtxt},
        success: function (callback) {
            var data = eval(callback);
            var daily_column = eval(data['columns']);
            var daily_data = eval(data['data']);
            // $("#panel_moneyflow").empty();
            // $("#panel_moneyflow").append("<table id='table_moneyflow'></table> ");

            $("#div_moneyflow").empty();
            $("#div_moneyflow").append("<div style='color: #ffffff' align='center'>" + searchtxt + ":资金流向</div>");
            $("#div_moneyflow").append("<table id='table_moneyflow' class='selected_stock'></table> ");
            $("#table_moneyflow").append("<tbody id='tbody_moneyflow'></tbody> ");
            $("#tbody_moneyflow").append("<tr id='tr_moneyflow_title' class='selected_stock'></tr> ");
            /*
            小单、中单的都不显示
             */
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['trade_date'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['buy_lg_vol'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['buy_lg_amount'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['sell_lg_vol'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['sell_lg_amount'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['buy_elg_vol'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['buy_elg_amount'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['sell_elg_vol'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['sell_elg_amount'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['net_mf_vol'] + "</th> ");
            $("#tr_moneyflow_title").append("<th scope='col' class='selected_stock'>" + daily_column['net_mf_amount'] + "</th> ");


            for (i = 0; i < daily_data.length; ++i) {
                $("#tbody_moneyflow").append("<tr></tr> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['ts_code'] + "</td> ");
                $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['trade_date'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['buy_sm_vol'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['buy_sm_amount'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['sell_sm_vol'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['sell_sm_amount'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['buy_md_vol'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['buy_md_amount'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['sell_md_vol'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['sell_md_amount'] + "</td> ");
                /*
                判断主力流入流出，
                 */
                buy_lg = daily_data[i].fields['buy_lg_amount'];
                buy_elg = daily_data[i].fields['buy_elg_amount'];
                sel_lg = daily_data[i].fields['sell_lg_amount'];
                sel_elg = daily_data[i].fields['sell_elg_amount'];
                main_flow = buy_elg + buy_lg - sel_elg - sel_lg;
                if (main_flow > 0) {
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['buy_lg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['buy_lg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['sell_lg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['sell_lg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['buy_elg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['buy_elg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['sell_elg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['sell_elg_amount'] + "</td> ");
                } else {
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['buy_lg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['buy_lg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['sell_lg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['sell_lg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['buy_elg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['buy_elg_amount'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['sell_elg_vol'] + "</td> ");
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['sell_elg_amount'] + "</td> ");
                }
                ////////////
                $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['net_mf_vol'] + "</td> ");
                // $("#tbody_moneyflow:last-child").append("<td class='selected_stock'>" + daily_data[i].fields['net_mf_amount'] + "</td> ");
                if (daily_data[i].fields['net_mf_amount'] > 0) {
                    $("#tbody_moneyflow:last-child").append("<td style='color: #dc3545' class='selected_stock'>" + daily_data[i].fields['net_mf_amount'] + "</td> ");
                } else {
                    $("#tbody_moneyflow:last-child").append("<td style='color: greenyellow' class='selected_stock'>" + daily_data[i].fields['net_mf_amount'] + "</td> ");
                }

            }
        },
        error: function () {
            alert('资金流查询失败');
        }
    })
}

function query_stock_K_line() {
    /*
      查询股票sina网动态K线图
     */

    $.ajax({
        url: '/stock/get_selected_stock/',
        type: "GET",
        data: {
            cmd_class: 'query',
            command: 'K_line',
            stock_name: show_selected_stock_name,
            ts_code: show_selected_ts_code
        },
        success: function (data) {
            $("#div_K_line_info").empty();
            $("#div_K_line_info").html(data);
        }
    });
}

